import request from "./useRequests";
import { userinfo } from '@/stores/counter'
import { ElMessage } from 'element-plus'

export default function getSubArticleList() {
  const user = userinfo()
  async function subList(cate: number) {
    try {
      const res = await request({
        method: "get",
        url: `/article/cate`,
        params: {
          "page": user.pages.sub.page,
          "size": 3,
          "cate": cate
        }
      })
      user.pages.sub.list.push(...res.data.data.items)
      user.pages.sub.cate = cate
      user.pages.sub.total = res.data.data.total
      // console.log(user.pages.sub)
    } catch (err: any) {
      // alert(err)
    }
  }

  return {
    subList
  }
}